<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- Bootstrap CSS-->
    <link rel="stylesheet" href="${pageContext.request.contextPath}/vendor/bootstrap/css/bootstrap.css">
    <!-- Font Awesome CSS-->
    <link rel="stylesheet" href="${pageContext.request.contextPath}/vendor/font-awesome/css/font-awesome.min.css">
    <!-- Custom Font Icons CSS-->
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/font.css">
    <!-- theme stylesheet-->
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/style.default.css" id="theme-stylesheet">
    <!-- Custom stylesheet - for your changes-->
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/custom.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/bootstrap/css/bootstrap-select.min.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/layer.css">
    <title>个人中心</title>

</head>
<body>
<%@include file="header.jsp"%>

<div class="d-flex align-items-stretch">
    <!-- Sidebar Navigation-->
    <%@include file="nav.jsp"%>
    <!-- Sidebar Navigation end-->
    <div class="page-content">
        <div class="page-header">
            <div class="container-fluid">
                <h2 class="h5 no-margin-bottom">个人中心</h2>
            </div>
        </div>
        <%
            request.getSession().getAttribute("user");
        %>
        <section class="no-padding-bottom">
            <div class="col-lg-12">
                <div class="block">
                    <div class="title"><strong>我的头像</strong></div>
                    <div class="avatar"><img src="${user.pic}" id='pic'
                                             alt="加载中..." style="width: 150px;height: 150px"
                                             class="img-thumbnail rounded-circle"></div>
                    <div style="margin-top: 15px" class="text-left">

                        <!-- 真正的文件上传表单 -->
                        <input name="realFile" type="file" id="picFile" style="display: none"/>
                    </div>
                    <div class="title">
                        <br>
                        <p class="h5"><strong>关注数：</strong><span>&nbsp;</span><span>&nbsp;</span><span>52</span></p>
                        <br>
                        <p class="h5"><strong>被看数：</strong><span>&nbsp;</span><span>&nbsp;</span><span>1168</span></p>
                        <br>
                    </div>
                    <div class="title"><strong>我的数据</strong></div>
                    <div class="block-body">
                        <form class="form-horizontal" action="${pageContext.request.contextPath}/user/update"
                              method="post">
                            <div class="form-group row">
                                <label class="col-sm-3 form-control-label">真实姓名</label>
                                <div class="col-sm-9">
                                    <input type="text" value="${sessionScope.user.realName}" class="form-control"
                                           name="name" >
                                </div>
                            </div>
                            <div class="line"></div>
                            <div class="form-group row">
                                <label class="col-sm-3 form-control-label">所属部门</label>
                                <div class="col-sm-9">
                                    <select class="selectpicker" data-live-search="true">
                                        <option>${sessionScope.user.deptName}</option>
                                    </select>
                                </div>
                            </div>
                            <div class="line"></div>
                            <div class="form-group row">
                                <label class="col-sm-3 form-control-label">电话</label>
                                <div class="col-sm-9">
                                    <input type="text" value="${sessionScope.user.phone}" name="phone"
                                           class="form-control">
                                </div>
                            </div>
                            <div class="line"></div>
                            <div class="form-group row">
                                <label class="col-sm-3 form-control-label">年龄</label>
                                <div class="col-sm-9">
                                    <input type="text" value="${sessionScope.user.age}" class="form-control" name="age">
                                </div>
                            </div>
                            <div class="form-group row">
                                <label class="col-sm-3 form-control-label">性别 </label>
                                <div class="col-sm-9">

                                    <div class="i-checks">

                                        <input id="radioCustom1" type="radio" value="1" name="gender" checked="${sessionScope.user.gender==1?'true':'false'}" disabled=""
                                               class="radio-template">
                                        <label for="radioCustom1">男</label>
                                        <span>&nbsp;</span><span>&nbsp;</span><span>&nbsp;</span>
                                        <input id="radioCustom2" type="radio" value="0" name="gender" checked="${sessionScope.user.gender==0?'true':'false'}" disabled=""
                                               class="radio-template">
                                        <label for="radioCustom2">女</label>
                                    </div>
                                </div>


                            </div>
                            <div class="line"></div>
                            <div class="form-group row">
                                <label class="col-sm-3 form-control-label">注册时间</label>
                                <div class="col-sm-9">
                                    <input type="text" disabled="" placeholder="${sessionScope.user.registerTime}"
                                           class="form-control">
                                </div>
                            </div>
                            <div class="line"></div>
                            <div class="form-group row">
                                <label class="col-sm-3 form-control-label">登录时间</label>
                                <div class="col-sm-9">
                                    <input type="text" disabled="" placeholder="${sessionScope.user.loginTime}"
                                           class="form-control" name="loginTim">
                                </div>
                            </div>
                            <div class="line"></div>

                            <div class="form-group row">
                                <label class="col-sm-3 form-control-label">是否私密 <br>
                                    <small class="text-primary">默认为否，可以不设置</small>
                                </label>
                                <div class="col-sm-9">
                                    <div class="i-checks">
                                        <input id="checkboxCustom1" type="checkbox" value="" class="checkbox-template" checked>
                                        <label for="checkboxCustom1">是否私密</label>
                                        <input type="hidden"  name="secret" value="${sessionScope.user.isSecret==0?0:1}" id="h0">
                                    </div>
                                </div>
                            </div>
                            <div class="line"></div>
                            <div class="text-center">
                                <input type="submit" class="btn btn-primary" value="保存">
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </section>
        <%@include file="footer.jsp"%>
    </div>
</div>

<!-- JavaScript files-->
<%@include file="floor.jsp"%>
<script type="text/javascript">

    $("#pic").click(function () {

        $("#picFile").click();

    });
    $('#picFile').change(function () {
            var formData = new FormData();
            formData.append("iconFile", document.getElementById("picFile").files[0]);
            $.ajax({
                url: "/user/updatePic",
                processData: false,
                contentType: false,
                data: formData,
                type: "post",
                async: true,
                success: function (res) {
                        $("#picFile").val("");
                        $("#pic").attr("src", res);
                        $("#loginUserPic").prop("src", res);
                }, error: function (data) {
                }
            })
        }

    );
    $("#checkboxCustom1").on("click",function () {
        if (this.checked===false){
            $("#h0").val(0)
        } else {
            $("#h0").val(1)
        }
    })
</script>
</body>
</html>